<template>
	<div>
		<div class="item">
			<div class="label">投注幣種</div>
			<div class="con">
				<!--自定义读取-->
				<div style="width:100%;">
					<div class="c-red" v-if="dev">测试网只能用提供的自定支持币种</div>
					<div>
						<el-button
							size="small"
							v-for="item in betCoinSupport"
							:key="item.symbol"
							:type="item.symbol==betCoinSelected?'primary':'info'"
							@click="actSelectCoin(item.symbol)"
							round
						>
							{{item.name}}
						</el-button>
					</div>
					<div v-show="betCoinSelected=='CUSTOM'">
						<el-input
							type="textarea" class="mt5"
							:autosize="{ minRows: 2, maxRows: 4}"
							placeholder="請輸入幣合約地址，并點擊下方讀取按鈕"
							v-model="betCoinInputPrivate"
							@input="actOnbetCoinChange"
							clearable
						>
						</el-input>
						<div class="mt5">
							<el-button size="small" type="success" round @click="actGetCustomTokenInfo()">讀取幣種信息</el-button>
						</div>
						<div v-if="betCoinData.decimal > 0">
							<div>幣種名稱：{{betCoinData.symbol}}</div>
							<div>幣種精度：{{betCoinData.decimal}}</div>
						</div>
						<!--<div class="c-red" v-else>幣種無效，請先讀取</div>-->
					</div>
				</div>
			</div>
		</div>

		<div class="item">
			<div class="label">投注範圍</div>
			<div class="con">
				<el-input class="w100" size="small" v-model="submitObject.bet_min_amount" placeholder="最小" type="number" clearable></el-input>
				~
				<el-input class="w100" size="small" v-model="submitObject.bet_max_amount" placeholder="最大" type="number" clearable></el-input>
			</div>

		</div>
		<div class="item">
			<div class="label">獎池注入</div>
			<div class="con">
				<el-input class="w80" size="small" v-model="submitObject.totalBetL" disabled>USDT</el-input>
				<!--<span class="c-red">輸入時即時計算</span>-->
				<span v-if="betCoinData.decimal > 0">{{betCoinData.symbol}}</span>
				<el-popover placement="top-end" title="提示" width="200" trigger="click" content="賽事獎池，需要打入的投注幣數量（目前的算法：所有賠率總和*最大投注）">
					<i class="f24 el-icon-question" slot="reference"></i>
				</el-popover>
				<!--<el-button type="success" size="small" @click="funcComputeJackpot()">預覽計算</el-button>-->
			</div>
		</div>
		<div class="item">
			<div class="label">質押票數</div>
			<div class="con">
				{{lockUpAmount + xg.name}}
				<el-popover placement="top-end" title="提示" width="200" trigger="click" content="需要質押的代幣數量。投票失敗、作廢、投票成功賽事開獎後，方可取回">
					<i class="f24 el-icon-question" slot="reference"></i>
				</el-popover>
			</div>
		</div>
	</div>
</template>

<script>
import { mixins } from "@/mixins/mixins";

export default {
	name: "createVoteMoney",
	props:[
		'submitObject',
		'betCoinData',
		'betCoinSupport',
		'betCoinSelected',
		'betCoinInput',
		'lockUpAmount',
	],
	mixins:[mixins],
	data(){
		return{
			//由于本组件内使用betCoinInput是通过v-model绑定的
			// 无法自动更新到父组件，所以这里另起了一个新值，再用update事件发送回去
			betCoinInputPrivate : this.betCoinInput
		}
	},
	computed:{
	},
	methods:{
		actSelectCoin (value) {
			this.$emit('actSelectCoin', value)
		},

		actGetCustomTokenInfo(value){
			this.$emit('actGetCustomTokenInfo',value)
		},
		//改变币种地址的时候,发送更新
		actOnbetCoinChange(){
			this.$emit('update:betCoinInput',this.betCoinInputPrivate)
		}
	},
	watch: {
		'betCoinInput______': {
			handler (nv, ov) {
				if(ov != nv){
					console.log('改变了币种输入')
					this.actOnbetCoinChange(nv)
				}
			},
			deep: false,
			immediate: true
		}
	},
}
</script>

<style lang="less">

</style>
